package cn.flant.io.tcp;

import java.net.Socket;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class SocketContext {
	private Map<String, Object> context = new ConcurrentHashMap<String, Object>();
	private Socket socket;

	protected SocketContext(Socket socket) {
		this.socket = socket;
	}

	public Socket getSocket() {
		return socket;
	}

	public void put(String key, String value) {
		context.put(key, value);
	}

	public Object get(String key) {
		return context.get(key);
	}

	public Object remove(String key) {
		return context.remove(key);
	}

	public Iterator<String> keyIterator() {
		return context.keySet().iterator();
	}

	public Set<String> getKeySet() {
		return context.keySet();
	}

	public void clear() {
		context.clear();
	}

	public boolean hasKey(String key) {
		return context.containsKey(key);
	}

	public boolean hasValue(Object value) {
		return context.containsValue(value);
	}
}
